<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>OpenVPN 监控系统</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
</head>
<body>
    <div class="container">
        <header class="header">
            <h1><i class="fas fa-shield-alt"></i> OpenVPN 监控系统</h1>
            <nav class="nav">
                <a href="/" class="nav-link active"><i class="fas fa-home"></i> 首页</a>
                <a href="/online" class="nav-link"><i class="fas fa-users"></i> 在线用户</a>
                <a href="/history" class="nav-link"><i class="fas fa-history"></i> 连接历史</a>
            </nav>
        </header>

        <main class="main">
            <div class="dashboard">
                <div class="card">
                    <div class="card-header">
                        <h2><i class="fas fa-server"></i> 系统概览</h2>
                    </div>
                    <div class="card-content">
                        <div class="stats-grid">
                            <div class="stat-item">
                                <div class="stat-icon">
                                    <i class="fas fa-users"></i>
                                </div>
                                <div class="stat-info">
                                    <h3 id="online-count">0</h3>
                                    <p>当前在线用户</p>
                                </div>
                            </div>
                            <div class="stat-item">
                                <div class="stat-icon">
                                    <i class="fas fa-network-wired"></i>
                                </div>
                                <div class="stat-info">
                                    <h3 id="total-traffic">0 B</h3>
                                    <p>总流量使用</p>
                                </div>
                            </div>
                            <div class="stat-item">
                                <div class="stat-icon">
                                    <i class="fas fa-clock"></i>
                                </div>
                                <div class="stat-info">
                                    <h3 id="avg-duration">0分钟</h3>
                                    <p>平均在线时长</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="card">
                    <div class="card-header">
                        <h2><i class="fas fa-chart-line"></i> 实时监控</h2>
                        <button class="refresh-btn" onclick="refreshData()">
                            <i class="fas fa-sync-alt"></i> 刷新
                        </button>
                    </div>
                    <div class="card-content">
                        <div id="online-users-list" class="users-list">
                            <div class="loading">
                                <i class="fas fa-spinner fa-spin"></i>
                                <p>正在加载数据...</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>

        <footer class="footer">
            <p>&copy; 2024 OpenVPN 监控系统. 服务器: {{ config.OPENVPN_HOST }}:{{ config.OPENVPN_PORT }}</p>
        </footer>
    </div>

    <script src="{{ url_for('static', filename='js/main.js') }}"></script>
</body>
</html> 